package cm.unit2.theme3;

public class SearchingTwoDimensionalArray {
	
	public boolean Find(int target, int [][] array) {
        if(array.length <= 0 || array[0].length <= 0 ){
            return false;
        }
        // 3.从左下角(或右上角)进行排除
        int x = 0 ;
        int y = array[0].length - 1;
        
        while(x <= array.length - 1 && y >= 0){
            if(array[x][y] == target){
                return true;
            }else if(array[x][y] < target){
                x += 1;
            }else if(array[x][y] > target){
                y -= 1;
            }
        }
        return false;
    }

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
